#include<iostream>
#include<jsoncpp/json/json.h>
#include<sstream>
std::string Serialize(const Json::Value& val)
{
    Json::StreamWriterBuilder writebuild;
    writebuild["emitUTF8"]=true;
    static Json::StreamWriter* writer=writebuild.newStreamWriter();
    std::stringstream os;
    writer->write(val,&os);
    return os.str();
}
void UnSerialize(Json::Value* val,const std::string& str)
{
    Json::CharReaderBuilder charreader;
    static Json::CharReader* reader=charreader.newCharReader();
    char buffer[1024]={0};
    reader->parse(&str[0],&str[0]+str.size(),val,nullptr);
}
int main()
{
    Json::Value val;
    val["姓名"]="张三";
    val["年龄"]=18;
    std::string str;
    str=Serialize(val);
    std::cout<<str<<std::endl;
    Json::Value deval;
    UnSerialize(&deval,str);
    std::cout<<"姓名:"<<deval["姓名"].asString()<<std::endl;
    std::cout<<"年龄:"<<deval["年龄"].asInt()<<std::endl;
}